<template>
	
	<el-table :data="informs" style="width: 100%">
		<el-table-column prop="informId" label="通知编号" width="180" />
	    <el-table-column prop="informTitle" label="通知标题" width="180" />
		<el-table-column prop="informTarget" label="通知对象" width="180"/>
		<el-table-column prop="informTime" label="发布时间" width="200" />
		<el-table-column width="100">
			<template #default="scope">
				<!-- <v-if informs.informState==0><el-button  type="success" @click="open(scope.row)">修改</el-button></v-if> -->
				<el-button  type="primary" @click="open(scope.row)">修改</el-button>
			</template>	
		</el-table-column>
		<el-table-column>
			<template #default="scope">
			    <el-button type="danger" @click="Delete(scope.row.informId)">撤销</el-button>
			</template>	
		</el-table-column>
	 </el-table>
	 
	  <!-- 修改通知提示框 -->
	  <el-dialog v-model="informConcent" title="修改通知">
		<el-form :model="updateinforms" label-width="120px">
		  		<el-form-item label="通知作者" >
		  		      <el-input placeholder="请输入作者" v-model="updateinforms.informAuther" style="width: 300px;"/>  
		  		</el-form-item>
		  		<el-form-item label="通知标题">
		  		      <el-input placeholder="请输入通知标题" v-model="updateinforms.informTitle" style="width: 300px;"/>  
		  		</el-form-item>
		  		<el-form-item label="通知人员">
		  			 <el-input placeholder="请输入通知人员" v-model="updateinforms.informTarget" style="width: 300px;"/>  
		  		</el-form-item>
		  		<el-form-item label="通知正文">
		  			<el-input
		  			    v-model="updateinforms.informConcent"
		  			    :autosize="{ minRows: 3, maxRows: 8 }"
		  			    type="textarea"
		  			    placeholder="请输入通知正文"
		  			  />
		  		</el-form-item>
				<el-form-item label="通知附件">
				{{updateinforms.informAcc}}
				</el-form-item>
		</el-form>
		  <el-button  type="primary" @click="upstate">发布</el-button>
		   <el-button  type="success" @click="saveupdate">保存</el-button>
		  <el-button  type="primary" @click="informConcent=false">关闭</el-button>
		  
			 
		  
	  </el-dialog>

</template>

<script>
	import qs from 'qs'
	export default{
		data() {
			return {
				informs:[],
				updateinforms:{},
				informConcent:false,
				id:0
			}
		},
		methods:{
			open(row){
				this.updateinforms=row
				this.informConcent=true
				
			},
			close(){
				this.informConcent=false
			},
			upstate(){
				let that=this
				let str=qs.stringify(that.updateinforms)
				this.$axios.get("http://localhost:8080/inform/upstate?"+str).then(function(res){
				informConcent=false
			})
			},
			saveupdate(){
				let that=this
				let str=qs.stringify(that.updateinforms)
				this.$axios.get("http://localhost:8080/inform/update?"+str).then(function(res){
				informConcent=false
			})
			},
			Delete(id){
				let that=this
				let str=qs.stringify(that.id)
				this.$axios.get("http://localhost:8080/inform/delete",{
					params:{
						informId:id
					}
				}).then(function(res){
				if(res.data==true){
					alert("撤销成功")
				}
				else{
					alert("撤销失败")
				}
				})
				
			}

		},
		created(){
			let that=this
			let u=JSON.parse(sessionStorage.getItem("user"))
			let str=qs.stringify(u)
			console.log(u)
			this.$axios.get("http://localhost:8080/inform/perlist?"+str).then(function(res){
				that.informs=res.data	
			})
			
		}
	}
</script>

<style>
</style>
